import { mapState , mapMutations } from 'vuex';
import listCell from '@/components/mix-list-cell';
import { userLogout } from '@/api/user.js';

export default {
	components: {
		listCell
	},
	data() {
		return {
		};
	},
	computed: {
		...mapState(['hasLogin'])
	},
	methods: {
		...mapMutations(['logout']),
		async toLogout() {
			//没有登录，直接跳过
			if(!this.hasLogin){
				return;
			}
			//后端api退出系统
			userLogout().then(response => {
				
			});
			//状态管理
			this.logout();
			
			uni.removeStorageSync("user");
			uni.removeStorageSync("token");
			
			uni.switchTab({url:'/pages/user/user'});
		}
	},
}